<include file="public@header"/>

</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('Article/index')}">所有文章</a></li>
        <li><a href="{:url('Article/add')}">添加文章</a></li>
    </ul>
        <form class="well form-inline margin-top-20" method="get"  action="{:url('Article/index')}">
            <input type="text" class="form-control" value="{$Request.param.title}" name="title" style="width: 150px;"  placeholder="请输入文章标题">
            <input class="js-bootstrap-datetime form-control" type="text"  id="input-datetime1" placeholder="请选择初始时间" value="{$Request.param.start_time}" name="start_time">
            -
            <input class="js-bootstrap-datetime form-control" type="text" id="input-datetime2" placeholder="请选择结束时间" value="{$Request.param.end_time}" name="end_time">
            <input type="submit" class="btn btn-primary" value="搜索" />
            <a class="btn btn-danger" href="{:url('Article/index')}">清空</a>
        </form>
    <form  method="post" class="margin-top-20" action="{:url('Article/delAll')}">
        <button class="btn btn-xs btn-danger" onclick="delCheck()">批量删除</button>
        <table class="table table-hover table-bordered">
            <thead>
            <tr>
                <th>
                    <input type="checkbox" onclick="checkAll(this)">
                </th>
                <th>ID</th>
                <th>标题</th>
                <th>背景</th>
                <th>作者</th>
                <th>分类</th>
                <th>浏览量</th>
                <th>描述</th>
                <th>是否推荐</th>
                <th>文章状态</th>
                <th>创建时间</th>
                <th>{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="data" item="vo">
                <tr>
                    <td>
                    <input type="checkbox" name="ids[]" value="{$vo.art_id}" >
                    </td>
                    <td>{$vo.art_id}</td>
                    <td>{$vo.title}</td>
                    <td><img src="/upload/{$vo.image}" width="50px"></td>
                    <td>
                        {$vo.author}
                    </td>
                    <td>{$vo.Category.category_name}</td>
                    <td>{$vo.read_num}</td>
                    <td>{$vo.desc}</td>
                    <td>
                        <switch name="$vo.is_recom">
                            <case value='1'>
                                <a href="{:url('article/check',array('art_id' => $vo['art_id'],'type' => 1))}" type="button" class="label label-success js-ajax-dialog-btn" >推荐</a>
                            </case>
                            <case value='2'>
                                <a href="{:url('article/check',array('art_id' => $vo['art_id'],'type' => 2))}" type="button" class="label label-success js-ajax-dialog-btn" >不推荐</a>
                            </case>
                        </switch>
                    </td>
                    <td>
                        <switch name="$vo.status">
                            <case value='1'>
                                <a href="{:url('article/check2',array('art_id' => $vo['art_id'],'type' => 1))}" type="button" class="label label-success js-ajax-dialog-btn" >显示</a>
                            </case>
                            <case value='2'>
                                <a href="{:url('article/check2',array('art_id' => $vo['art_id'],'type' => 2))}" type="button" class="label label-success js-ajax-dialog-btn" >隐藏</a>
                            </case>
                        </switch>
                    </td>
                    <td>{$vo.create_time}</td>
                    <td>
                        <a class="btn btn-xs btn-primary" href="{:url('Article/news')}?art_id={$vo.art_id}">查看</a>
                        <a class="btn btn-xs btn-success"  href="{:url('Article/edit')}?art_id={$vo.art_id}">{:lang('EDIT')}</a>
                        <a class="btn btn-xs btn-danger js-ajax-delete" href="{:url('Article/delete')}?art_id={$vo.art_id}">{:lang('DELETE')}</a>
                    </td>
                </tr>
            </foreach>
            </tbody>

        </table>
        <div class="pagination" style = "margin-left:500px">
            <div class="pagination" >
                {$page}
            </div>
            <div class="">
                共 {$data->total()} 条数据，当前第 {$data->currentPage()} 页，共 {$data->lastPage()} 页
            </div>
        </div>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    //全选
    function checkAll(e) {
        var item = document.getElementsByName('ids[]');
        for (var i = 0; i < item.length; i++)
        {
            item[i].checked = e.checked;
        }
    }
    //全选删除
    function delCheck() {
        var isCheck = false;
        var item = document.getElementsByName('ids[]');
        for (var i = 0; i < item.length; i++)
        {
            if (item[i].checked)
            {
                isCheck = true;
            }
        }
        if (isCheck)
        {
            return confirm('确定删除吗？');
        } else {
            alert('请至少选择一项！');
            // layer.msg('请至少选择一项');
            return false;
        }
    }


</script>
</body>
</html>